package cn.ym.service.impl;

import cn.ym.domain.OperLog;
import cn.ym.mapper.OperLogMapper;
import cn.ym.query.OperLogQuery;
import cn.ym.service.OperLogService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * 日志的业务层
 */
@Service
public class OperLogServiceImpl implements OperLogService {

    @Autowired
    private OperLogMapper operLogMapper;

    @Override
    public void add(OperLog operLog) {
        operLogMapper.add(operLog);
    }

    @Override
    public void update(OperLog operLog) {
        operLogMapper.update(operLog);
    }

    @Override
    public void delete(Long id) {
        operLogMapper.delete(id);
    }
    @Override
    public void Patchdel(Long[] ids) {
        operLogMapper.Patchdel(ids);
    }
    @Override
    public OperLog findOne(Long id) {
        return operLogMapper.findOne(id);
    }

    @Override
    public List<OperLog> findAll() {
        return operLogMapper.findAll();
    }


    @Override
    public List<OperLog> queryPage(OperLogQuery operLogQuery) {
        //开启分页
        /**1.自动计算总数量
         * 2.根据驱动名计算 limit的第一个参数
         * 3.分页返回结果
         */
       PageHelper.startPage(operLogQuery.getCurrentPage(), operLogQuery.getPageSize());
       return operLogMapper.queryPage(operLogQuery);
    }
}